<template>
  <div>
    <city-header></city-header>
    <city-search></city-search>
    <city-list :hot="hotCities" :city="cities" :letter="letter"></city-list>
    <city-fixed :city="cities" @letter="handleletter"></city-fixed>
  </div>
</template>
<script>
import axios from 'axios'
import CityHeader from '@/pages/city/components/Header'
import CitySearch from '@/pages/city/components/Searchs'
import CityList from '@/pages/city/components/List'
import CityFixed from '@/pages/city/components/Fixed'
export default{
  name: 'City',
  components: {
    CityHeader: CityHeader,
    CitySearch: CitySearch,
    CityList: CityList,
    CityFixed: CityFixed
  },
  data: function () {
    return {
      cities: {},
      hotCities: [],
      letter: ''
    }
  },
  methods: {
    getCityInfo: function () {
      axios.get('/api/city.json').then(this.handleGetCityInfo)
    },
    handleGetCityInfo: function (res) {
      var data = res.data
      this.cities = data.data.cities
      this.hotCities = data.data.hotCities
    },
    handleletter: function (result) {
      this.letter = result
    }
  },
  mounted: function () {
    this.getCityInfo()
  }
}
</script>
<style lang="stylus" scoped>
</style>
